package com.alibaba.algo.dao.user;

import com.alibaba.algo.Application;
import com.alibaba.algo.domain.user.SysUserAppDTO;
import com.alibaba.algo.entity.user.SysUserApp;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

/**
 * @author : WangZhiPan
 * @date : 2021/9/30 10:53
 */
@SpringBootTest(classes = Application.class)
@RunWith(SpringRunner.class)
@Slf4j
public class SysUserAppMapperTest {

    @Autowired
    private SysUserAppMapper appMapper;


    @Test
    public void testPage() {
        Page<SysUserAppDTO> page = new Page<>();
        page.pageNum(1);
        page.pageSize(10);
        page.setOrderBy("user_id desc");
        PageHelper.startPage(page.getPageNum(), page.getPageSize(),page.getOrderBy());
        SysUserApp param = new SysUserApp();
        param.setAppCode("MOM");
        List<SysUserAppDTO> resp = appMapper.list(param);
        PageInfo<SysUserAppDTO> pageInfo = new PageInfo<>(resp);
        log.info("resp={}", JSON.toJSONString(pageInfo));
    }
}
